<div class="main_body">
    <?php echo $this->element('main_menu')?>		
	<div id="main_body_content">
	
	
		<div class="orders index">
			<h1><?php __("Orders");?></h1>
			<table cellpadding="3" cellspacing="0">
			<tr>
					<th><?php echo __("Day",true)?></th>
					<th class="actions"><?php echo __("Employees/Orders",true)?></th>
			</tr>
			<?php
			$i = 0;
			foreach ($orders as $date => $employees):
				$class = null;
				if ($i++ % 2 == 0) {
					$class = ' class="altrow"';
				}
			?>
			<tr<?php echo $class;?>>
				<td width="10%" valign="top" align="center">
					<?php echo $time->format("M d D Y",$date)?>
				</td>
				<td class="actions" width="90%" valign="top">
					<?php 
						$rozdziel_employees = (count($employees) == 1)?"":'class="rozdziel_employee"';
						$class__ = "";
					?>
					<table cellpadding="3" cellspacing="3" class="czysta">
						<?php
						$j = 0;						
						foreach ($employees as $employee_id => $employee):
							$class_ = null;
							if ($j++ % 2 == 0) {
								$class_ = ' class="altrow_employee"';
							}
							if($j >= 2){
								$class__ = $rozdziel_employees;
							}
						?>
						<tr<?php echo $class_;?>>
							<td width="20%" <?php echo $class__?>>
								<?php echo $employee['emplo']['name'].' '.$employee['emplo']['surname']?><br/>
								<?php echo $employee['emplo']['phone1']?><br/>
								<?php echo $typeOfWorks[$employee['emplo']['type_of_work_id']]?> 
								<?php echo (!empty($employee['emplo']['type_of_work_2_id'])) ? $typeOfWorks[$employee['emplo']['type_of_work_2_id']]: ""?> 
								<?php echo (!empty($employee['emplo']['type_of_work_3_id'])) ? $typeOfWorks[$employee['emplo']['type_of_work_3_id']]: ""?>
							</td>
							<td width="80%"  <?php echo $class__?>>
							
								<?php 
									$rozdziel_orders = (count($employee['orders']) == 1)?"":'class="rozdziel_orderse"';
									$class____ = "";
								?>							
								<table cellpadding="5" cellspacing="5" class="czysta">
									<?php
									$k = 0;
									foreach ($employee['orders'] as $orders_id => $order):
										$class___ = null;
										if ($k++ % 2 == 0) {
											$class___ = ' class="altrow_orders"';
										}
										if($k >= 2){
											$class____ = $rozdziel_orders;
										}										
									?>
									<tr<?php echo $class___;?>>
										<td width="50%" <?php echo $class____?>>
											<?php echo $order['TypesOfSpaces']['name']?> <?php echo $order['TypeOfService']['name']?><br/>
											<?php echo $order['Order']['estimated_execution_time']?> <?php echo __("hours",	true)?><br/>
											<?php echo $order['Order']['value_of_the_order']?> <?php echo __("USD",	true)?><br/>
										</td>
										<td width="50%" <?php echo $class____?>>
											<?php echo $order['Customer']['name'].' '.$order['Customer']['surname']?><br/>
											<?php echo $order['Customer']['address1'].' '.$order['Customer']['address2']?><br/>
											<?php echo $order['Customer']['address3'].' '.$order['Customer']['address4']?><br/>
											<?php echo __("Phone",true)." ".$order['Customer']['phone1']?>
										</td>
									</tr>
									<?php endforeach; ?>
								</table>
							
							</td>
						</tr>
						<?php endforeach; ?>
					</table>
				</td>
			</tr>
		<?php endforeach; ?>
			</table>
		</div>



		<div class="clr"></div>	
	</div>		
	<?php echo $this->element('languages')?>	
	<div class="clr"></div>
	<br/>
</div>	
<div class="clr"></div>	
<div class="main_action">
	<div class="main_action_content">
	
		<div class="actions">
			<h3><?php __("Actions"); ?></h3>
			<ul>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_print_index.png'), array('controller' => 'reports', 'action' => 'index'),array('escape'=>false,'title'=>__("New Report", true))); ?> <div class="clr"></div> <?php echo __("New Report", true)?></li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_print_pdf.png'), array('controller' => 'reports', 'action' => 'printPdf'),array('escape'=>false,'title'=>__("Print Report", true))); ?> <div class="clr"></div> <?php echo __("Print Report", true)?></li>
			</ul>
		</div>
		
		<div class="clr"></div>
	</div>		
</div>	
